package com.zzl.springboot_mybatis_demo.exception;

import com.zzl.springboot_mybatis_demo.enums.ResultEnum;
import lombok.Getter;

/**
 * description: 自定义响应异常
 * @author 朱正磊
 * @date 2019-08-29 10:22:47
 */
@Getter
public class ResponseException extends RuntimeException {

    private static final long serialVersionUID = 377374627333572755L;

    private Integer code;

    /**
     * description: 带有响应结果信息枚举的构造函数
     * @author 朱正磊
     * @date 2019-08-29 10:38:50
     * @param resultEnum 响应结果信息枚举
     */
    public ResponseException(ResultEnum resultEnum) {
        super(resultEnum.getMessage());
        this.code = resultEnum.getCode();
    }

    /**
     * description: 带有响应编码和响应信息的构造函数
     * @author 朱正磊
     * @date 2019-08-29 10:37:58
     * @param code 响应编码
     * @param message 响应信息
     */
    public ResponseException(Integer code, String message) {
        super(message);
        this.code = code;
    }

}
